package com.yf.dao;

import com.yf.bean.ExamBean;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

@Repository
public class ExamDao extends BaseDao {
//    public List<ExamBean> getAll() {
//        String s = getStatement("getAll");
//        return sessionTemplate.selectList(s);
//    }

    public Integer insert(Map<String, Object> params) {
        return sessionTemplate.insert(getStatement("insert"), params);
    }

    public Integer add408(ExamBean bean) {
        return sessionTemplate.insert(getStatement("addExam"), bean);
    }

    public Integer add408V2(ExamBean bean) {
        return sessionTemplate.insert(getStatement("addExamV2"), bean);
    }

    public Integer existProblem(ExamBean bean) {
        return sessionTemplate.selectOne(getStatement("existProblem"), bean);
    }

//    public Integer updateByYearNumber(ExamBean bean) {
//        return sessionTemplate.update(getStatement("updateByYearNumber"), bean);
//    }

    public ExamBean getProblemByYearNumber(Map<String, String> params) {
        return sessionTemplate.selectOne(getStatement("getProblemByYearNumber"), params);
    }

    public Integer updateById(ExamBean bean) {
        return sessionTemplate.update(getStatement("updateById"), bean);
    }

    public Integer updateByIdV2(ExamBean bean) {
        return sessionTemplate.update(getStatement("updateByIdV2"), bean);
    }

    public Integer getExamUid(Integer id) {
        return sessionTemplate.selectOne(getStatement("getExamUid"), id);
    }

    public List<ExamBean> getTargetQus(List<Long> ids) {
        return sessionTemplate.selectList(getStatement("getTargetQus"), ids);
    }

    public List<ExamBean> getQusById(List<Long> ids) {
        return sessionTemplate.selectList(getStatement("getQusById"), ids);
    }

    public ExamBean getQusForLog(Long id) {
        return sessionTemplate.selectOne(getStatement("getQusForLog"), id);
    }

    public List<ExamBean> getFixedQus(List<Long> ids) {
        return sessionTemplate.selectList(getStatement("getFixedQus"), ids);
    }

    public List<Integer> getQusIDByYear(Map<String, String> params) {
        return sessionTemplate.selectList(getStatement("getQusIDByYear"), params);
    }

    public ExamBean getQusByYearNumber(Map<String, String> params) {
        return sessionTemplate.selectOne(getStatement("getQusByYearNumber"), params);
    }

    public List<ExamBean> getOnlyQusMain(List<Long> ids) {
        return sessionTemplate.selectList(getStatement("getOnlyQusMain"), ids);
    }

    public List<ExamBean> getQusDescription(List<Integer> ids) {
        return sessionTemplate.selectList(getStatement("getQusDescription"), ids);
    }

    public ExamBean getQuestionById(Long id) {
        return sessionTemplate.selectOne(getStatement("getQuestionById"), id);
    }
}
